<?php
/**
 * AdminDepartmentDao
 *
 * @author fusq
 */
require_once BaseUtil::getModulePath("base") . '/models/BaseDao.php';

class AdminDepartmentDao extends BaseDao {
    
    protected $_name;

    public function  _setup() {
        $this->_name = $this->prefix() . "admin_departments";
        parent::_setup();
    }

    public function updateAdminDepartment($adminDepartment,$id){
        $where = $this->db_w->quoteInto('admin_id = ?', $id);
	    $this->updateData($adminDepartment,$where);
    }

    public function getDepartmentsByAdmin($adminId){
        $select = $this->db_r->select();
        $select->from($this->_name,"department_id");
        $select->where('admin_id = ?', $adminId);
        $select->where('is_delete = 0');
        $sql = $select->__toString();
        $result = $this->db_r->fetchAll($sql);
        return $result;
    }

    public function deleteAdminDepartment($adminId){
        $where = $this->db_w->quoteInto('admin_id = ?', $adminId);
        $this->delete($where);
    }
}
